﻿<WindowView
    x:Class="Poet.Views.EncodingView"
    Icon="/Poet;component/App.ico"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Height="{ViewModel DefaultValue=600}" 
    Width="{ViewModel DefaultValue=512}"
    Left="{ViewModel DefaultValue=NaN}" 
    Top="{ViewModel DefaultValue=NaN}" 
    WindowStartupLocation="CenterOwner"
    ResizeMode="CanResizeWithGrip"
    ShowInTaskbar="False"
    Title="Poet"
    Name="This">

    <WindowView.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="..\Resources\XamlStore.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </WindowView.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <ListView  
            Grid.Row="0" 
            Margin="4 4 4 0" 
            Name="ListView"
            ItemsSource="{Binding EncodingInfos}" 
            SelectedItem="{Binding CurrentEncodingInfo}" 
            GridViewExtensions.AutoSort="True"
            GridViewExtensions.SaveColumnOrder="True" 
            GridViewExtensions.SortDescriptionCollection="{Binding '[SortDescriptionCollection]'}">
            <ListView.View>
                <GridView>

                    <GridViewColumn 
                        DisplayMemberBinding="{Binding CodePage}" 
                        Width="{Binding '[CodePageColumnWidth,100]', Mode=TwoWay}" 
                        GridViewExtensions.PropertyName="CodePage" 
                        GridViewExtensions.MinWidth="64"
                        GridViewExtensions.Index="{Binding '[CodePageColumnIndex,0]'}">
                        <GridViewColumn.Header>
                            <GridViewColumnHeader>
                                <TextBlock Text="{Localizing CodePage}" IsHitTestVisible="False"/>
                            </GridViewColumnHeader>
                        </GridViewColumn.Header>
                    </GridViewColumn>

                    <GridViewColumn 
                        DisplayMemberBinding="{Binding Name}"
                        Width="{Binding '[NameColumnWidth,120]', Mode=TwoWay}" 
                        GridViewExtensions.PropertyName="Name"                      
                        GridViewExtensions.MinWidth="32"
                        GridViewExtensions.Index="{Binding '[NameColumnIndex,1]'}">
                        <GridViewColumn.Header>
                            <GridViewColumnHeader>
                                <TextBlock Text="{Localizing BodyName}" IsHitTestVisible="False"/>
                            </GridViewColumnHeader>
                        </GridViewColumn.Header>
                    </GridViewColumn>

                    <GridViewColumn 
                        DisplayMemberBinding="{Binding DisplayName}" 
                        Width="{Binding '[DisplayNameWidth,230]', Mode=TwoWay}" 
                        GridViewExtensions.PropertyName="DisplayName"                         
                        GridViewExtensions.MinWidth="32"
                        GridViewExtensions.Index="{Binding '[DisplayNameColumnIndex,2]'}">
                        <GridViewColumn.Header>
                            <GridViewColumnHeader>
                                <TextBlock Text="{Localizing DisplayName}" IsHitTestVisible="False"/>
                            </GridViewColumnHeader>
                        </GridViewColumn.Header>
                    </GridViewColumn>

                </GridView>
            </ListView.View>
        </ListView>

        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>

            <GroupBox 
                Grid.Column="0" 
                Margin="2 2 2 8" 
                Header="{Localizing Keywords, StringFormat='{}{0}:'}"
                ToolTipService.ShowDuration="32000000">
                <GroupBox.ToolTip>
                    <ToolTip>
                        <StackPanel Orientation="Vertical">
                            <TextBlock Text="{Localizing OrSeparators, StringFormat={}{0}:}" FontWeight="Bold"/>
                            <TextBlock Text="{Binding OrSeparators, Converter={StaticResource CharArrayToStringConverter}}"/>
                            <TextBlock Text="{Localizing AndSeparators, StringFormat={}{0}:}" FontWeight="Bold"/>
                            <TextBlock Text="{Binding AndSeparators, Converter={StaticResource CharArrayToStringConverter}}"/>
                        </StackPanel>
                    </ToolTip>
                </GroupBox.ToolTip>
                <TextBox Text="{Binding Keywords, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Margin="2" MinWidth="16" Width="100"/>
            </GroupBox>

            <GroupBox
                Grid.Column="1" 
                Margin="2 2 2 8" 
                Header="{Localizing Encoding}"     
                ToolTipService.ShowDuration="32000000">
                <GroupBox.ToolTip>
                    <ToolTip>
                        <ToolTip.Resources>
                            <Style TargetType="GroupBox">
                                <Setter Property="FontWeight" Value="Black"/>
                            </Style>
                            <Style TargetType="ColumnDefinition">
                                <Setter Property="MinWidth" Value="96"/>
                            </Style>
                            <Style TargetType="TextBlock">
                                <Setter Property="HorizontalAlignment" Value="Left"/>
                                <Setter Property="FontWeight" Value="Normal"/>
                                <Setter Property="Margin" Value="0 0 8 0"/>
                            </Style>
                        </ToolTip.Resources>

                        <GroupBox Header="{Localizing Encoding}" FontWeight="Bold"  DataContext="{Binding CurrentEncodingInfo}">
                            <Grid>
                                
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                
                                <Grid.RowDefinitions>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                </Grid.RowDefinitions>

                                <TextBlock Grid.Column="0" Grid.Row="0" Text="{Localizing CodePage}"/>
                                <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding CodePage}"/>
                                <TextBlock Grid.Column="0" Grid.Row="1" Text="{Localizing BodyName}"/>
                                <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding Name}"/>
                                <TextBlock Grid.Column="0" Grid.Row="2" Text="{Localizing DisplayName}"/>
                                <TextBlock Grid.Column="1" Grid.Row="2" Text="{Binding DisplayName}"/>

                            </Grid>
                        </GroupBox>
                    </ToolTip>
                </GroupBox.ToolTip>
                <TextBlock Text="{Binding CurrentEncodingInfo.DisplayName, TargetNullValue={Localizing None}, FallbackValue={Localizing None}}" VerticalAlignment="Center"/>
            </GroupBox>

            <StackPanel Grid.Column="2" Orientation="Horizontal" Margin="8" VerticalAlignment="Bottom">
                <Button Content="{Localizing Ok}" IsDefault="True" Click="ButtonBase_OnClick"/>
                <Button Content="{Localizing Cancel}" IsCancel="True"/>
            </StackPanel>
        </Grid>
    </Grid>
</WindowView>
